﻿using Catchbase.Model;
using Catchbase.Service.API;
using Catchbase.TestTools;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Catchbase.Service.ATest
{
    [TestClass]
    public class CatcherServiceTest : ServiceTest<Catcher>
    {
        [TestMethod]
        public void Get_ReturnsCatcher()
        {
            Service.Get(SecurityManager).Name.MustEqual("Frank Borg");
        }

        [TestMethod]
        [ExpectedException(typeof(AccessException))]
        public void Get_ReturnsUnautorized_WhenWrongusernameIsProvided()
        {
            Service.Get(new SecurityManager("Bogus@bologus.Com", Settings.SharedSecret));
        }

        [TestMethod]
        [ExpectedException(typeof(AccessException))]
        public void Get_ReturnsUnautorized_WhenWrongSecretKeyIsProvided()
        {
            Service.Get(new SecurityManager(Settings.GoogleUsername, "bogussecret"));
        }

        [TestMethod]
        [ExpectedException(typeof(AccessException))]
        public void Get_ReturnsUnautorized_WhenNoKeyIsProvided()
        {
            Service.Get();
        }
    }
}